package com.xdhl.fu.fi.controller;

import com.xdhl.fu.common.core.web.domain.AjaxResult;
import com.xdhl.fu.fi.repository.MGFlightAirportInfoRepository;
import com.xdhl.fu.flight.info.api.mongodb.domain.MGFlightAirportInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 机场标签控制器
 *
 * @author 朱力维
 * @time 2022/7/1 20:34
 */
@RestController
@RequestMapping("/airport-label")
public class FlightAirportLabelController {

    @Resource
    private MGFlightAirportInfoRepository flightAirportInfoRepository;

    /**
     * 按机场代码获取机场信息
     *
     * @param cityCode 机场代码
     * @return 机场信息
     */
    @GetMapping("/city-code/{cityCode}")
    public AjaxResult get(@PathVariable("cityCode") String cityCode) {
        MGFlightAirportInfo mgFlightAirportInfo = flightAirportInfoRepository.findByCityCodeEquals(cityCode);
        return AjaxResult.success(mgFlightAirportInfo);
    }

}
